import { h } from "hyperapp"

const EMPTY_ARR = []
const EMPTY_OBJ = {}

const tag = (tag) => (
  props,
  children = props.tag != null || Array.isArray(props) ? props : EMPTY_ARR
) => h(tag, props === children ? EMPTY_OBJ : props, children)

export const a = tag("a")
export const g = tag("g")
export const svg = tag("svg")
export const use = tag("use")
export const set = tag("set")
export const line = tag("line")
export const path = tag("path")
export const rect = tag("rect")
export const desc = tag("desc")
export const defs = tag("defs")
export const mask = tag("mask")
export const tref = tag("tref")
export const font = tag("font")
export const stop = tag("stop")
export const view = tag("view")
export const text_ = tag("text")
export const image = tag("image")
export const mpath = tag("mpath")
export const title = tag("title")
export const glyph = tag("glyph")
export const tspan = tag("tspan")
export const style = tag("style")
export const circle = tag("circle")
export const marker = tag("marker")
export const symbol = tag("symbol")
export const feTile = tag("feTile")
export const cursor = tag("cursor")
export const filter = tag("filter")
export const switch_ = tag("switch")
export const ellipse = tag("ellipse")
export const polygon = tag("polygon")
export const animate = tag("animate")
export const pattern = tag("pattern")
export const feBlend = tag("feBlend")
export const feFlood = tag("feFlood")
export const feFuncA = tag("feFuncA")
export const feFuncB = tag("feFuncB")
export const feFuncG = tag("feFuncG")
export const feFuncR = tag("feFuncR")
export const feImage = tag("feImage")
export const feMerge = tag("feMerge")
export const polyline = tag("polyline")
export const metadata = tag("metadata")
export const altGlyph = tag("altGlyph")
export const glyphRef = tag("glyphRef")
export const textPath = tag("textPath")
export const feOffset = tag("feOffset")
export const clipPath = tag("clipPath")
export const altGlyphDef = tag("altGlyphDef")
export const feComposite = tag("feComposite")
export const feMergeNode = tag("feMergeNode")
export const feSpotLight = tag("feSpotLight")
export const animateColor = tag("animateColor")
export const altGlyphItem = tag("altGlyphItem")
export const feMorphology = tag("feMorphology")
export const feTurbulence = tag("feTurbulence")
export const fePointLight = tag("fePointLight")
export const colorProfile = tag("colorProfile")
export const foreignObject = tag("foreignObject")
export const animateMotion = tag("animateMotion")
export const feColorMatrix = tag("feColorMatrix")
export const linearGradient = tag("linearGradient")
export const radialGradient = tag("radialGradient")
export const feGaussianBlur = tag("feGaussianBlur")
export const feDistantLight = tag("feDistantLight")
export const animateTransform = tag("animateTransform")
export const feConvolveMatrix = tag("feConvolveMatrix")
export const feDiffuseLighting = tag("feDiffuseLighting")
export const feDisplacementMap = tag("feDisplacementMap")
export const feSpecularLighting = tag("feSpecularLighting")
export const feComponentTransfer = tag("feComponentTransfer")
